package com.javajun.spider.bt7086.common;

import java.net.MalformedURLException;
import java.net.URL;

import org.apache.commons.lang3.StringUtils;

public class UrlUtils {

	public static String getFile(String url) {
		String filed = url;
		try {
			filed = new URL(url).getFile();
		} catch (MalformedURLException e) {
			System.err.println("url转换出错，url: " + url);
		}
		return filed;
	}
	
    public static String getPath(String url) {
        String host = url;
        int i = StringUtils.ordinalIndexOf(url, "/", 4);
        if (i > 0) {
            host = StringUtils.substring(url, 0, ++ i); //++i 的作用是去掉开头的斜杠/
        }
        String urlPath = url.replace(host, "");
       return urlPath;
    }

}
